package com.stars.services.impl.pshow;

import com.stars.dao.mapper.pshow.PShowCkMapper;
import com.stars.services.pshow.PShowCkConfigServices;
import com.stars.entity.pshow.PShowCkEntity;
import com.stars.dao.mapper.pshow.PShowCkMapper;

import org.springframework.stereotype.Service;

import com.stars.services.impl.BaseConfigServiceImpl;
import com.stars.common.base.BaseMsg;
import com.stars.common.annotation.FieldRepeatVailClass;
import com.stars.common.enums.SaveTypeEnum;
import com.stars.common.valid.MyException;
import com.stars.common.base.ResultMsg;
import java.util.List;
import com.stars.common.base.BaseConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;

/**
 * @Title: 仓库管理 业务逻辑
 * @author 肖伟
 * @date 2020-01-04
 * @version V1.0
 *
 */
@Service
public class PShowCkConfigServicesImpl extends BaseConfigServiceImpl<PShowCkMapper , PShowCkEntity> implements PShowCkConfigServices {
    @Autowired
    private PShowCkMapper pShowCkMapper;

    @Override
    @FieldRepeatVailClass(saveType = SaveTypeEnum.SAVE_ADD,saveBatch = true)
    public ResultMsg addImportExcel(List<PShowCkEntity> entityList, ResultMsg resultMsg) throws Exception {
        entityList.forEach(t->{
            if(resultMsg.isSuccess()){
                try {
                    t.setCreateDate(new Date());
                    insert(t);
                } catch (Exception e) {
                   throw new MyException(BaseMsg.SAVE_FAILURE+"，模板不正确.");
                }
            }
        });
        if(resultMsg.isHasErrors()){
            return resultMsg;
        }
        return ResultMsg.success();
    }



}